
<%@ page import="filmring.Movie" %>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="<g:resource dir='css' file='filmring.css' />"/>
        <g:javascript library="jquery" plugin="jquery" />
        <script type="text/javascript" src="<g:resource dir='js' file='twitter.js'/>"></script>
        <script type="text/javascript" src="<g:resource dir='js' file='ratings.js'/>"></script>
        <script type="text/javascript">
            $().ready(function(){
                queryTwitter("${movie.title.encodeAsURL()}");
                preloadimages();
                 $(".rating").each(function(index){
                    registerRatingsListeners2(index,($(".rating input")[index]).value,${session.user},"#"+$(this).attr('id'));
                });
            });
        </script>
        <title>Film Ring: ${movie.title}</title>
    </head>
    <body>
        <g:render template="/templates/topbar" />
        <div class="clear"></div>
        <g:render template="/templates/sidebar" model="${['user':user]}"/>
        <g:render template="/templates/moviesummary" model="${[movie:movie, rating:rating, avgRating:avgRating, img:img]}" />
        <g:render template="/templates/twitterfeed"  model="${[query:movie.title]}" />
        <div class="clear"></div>
        <g:each var="review" in="${movie.reviews}">
            <g:render template="/templates/review" model="${['review':review]}"   />
        </g:each>
        <g:if test="${session.signedIn}">
        <div class="review">
        <h4>Write your own review</h4>
        <g:form controller="review" action="review">
            <g:hiddenField name="movie" value="${movie.id}" />
            <g:hiddenField name="user" value="${session.user}" />
            <g:render template="/templates/ratingwidget" model="${[rating:rating.rating, id:'review/'+movie.id]}" />
            <br />
            <g:textArea name="review" rows="8" cols="100"/> <br />
            <g:submitButton name="submit" value="Submit" />
        </g:form>
        </div>
        </g:if>
    </body>
</html>
